<?php
/**
 * +-------------------------------------------------------------
 * |Caption:
 * +-------------------------------------------------------------
 * |Author: Lenny
 * +-------------------------------------------------------------
 * |Email:  1685964109@qq.com
 * +-------------------------------------------------------------
 * |Date:   2024/7/4 下午4:21
 * +-------------------------------------------------------------
 */

namespace app\admin\model;

use app\common\model\BaseModel;
use think\Model;
use think\model\relation\BelongsTo;

class Store extends BaseModel
{
    public function admin(): BelongsTo
    {
        return $this->belongsTo(StoreAdmin::class,'id','store_id');
    }

    public function owners(): BelongsTo
    {
        return $this->belongsTo(StoreOwners::class,'id','store_id');
    }

    public function bank(): BelongsTo
    {
        return $this->belongsTo(StoreBank::class,'id','store_id');
    }

//    public static function onAfterInsert(Model $model): void
//    {
//        $owners = Request()->post('owners');
//        $admin  = Request()->post('admin');
//        $owners = json_decode($owners, true);
//        $admin  = json_decode($admin, true);
//        $owners['store_id'] = $admin['store_id'] = $model->id;
//        StoreOwners::create($owners);
//        StoreAdmin::create($admin);
//    }
}